package com.test.junit_test;

public class BankAccount {

    private double balance;

    public BankAccount() {
        this.balance = 0.0;
    }

    // 存款
    public void deposit(double amount) {
        if (amount <= 0) {
            throw new IllegalArgumentException("Deposit amount must be positive");
        }
        balance += amount;
    }

    // 取款
    public void withdraw(double amount) {
        if (amount <= 0) {
            throw new IllegalArgumentException("Withdrawal amount must be positive");
        }
        if (balance < amount) {
            throw new IllegalArgumentException("Insufficient balance");
        }
        balance -= amount;
    }

    // 查询余额
    public double getBalance() {
        return balance;
    }
}

